from typing import List


class Solution:
    def removeElement(self, nums: List[int], val: int) -> int:
        i = 0
        length = len(nums)
        j = length - 1
        while i <= j:
            if nums[i] == val:
                nums[i], nums[j] = nums[j], nums[i]
                j -= 1
                length -= 1
            else:
                i += 1

        return length


if __name__ == '__main__':
    s = Solution()
    result = s.removeElement([2, 3, 2, 3], 3)
    print(result)
